// table 操作项
import { Button, Dropdown, Menu, message, Modal, DatePicker, Select } from 'antd'
import { useBoolean, useEventEmitter, useRequest } from 'ahooks'
import {
    SeeEnclosureModal,
    AddressSelectModal,
    LabHandleModal,
    CementMixingStationsModal,
    LabCoverProtectorModal,
    AsphaltCurveDatasModal,
    LabReboundHammerModal,
    ProjectFileMenuModal,
    SeeLabVideoModal,
    ProjectBuildingPaymentStatModal,
    OpenExcelUrlModal,
    SelectModal,
} from './Modal'
import { PlusOutlined } from '@ant-design/icons'
import { TableDropdown } from '@ant-design/pro-components'
import { QRcode, ExportExcel, CanvasQRcodeModal } from '../Configure/QRcode'
import { Http } from '../Api'
import { useState } from 'react'
import { ForgeBox } from '../Scenes/Forge/ForgeProgress'
import { WeChatMenuItem } from '../Configure/WeChatMenuItem'
import dayjs from 'dayjs'
import { useEffect } from 'react'
import { ModalBox } from './ModalBox'

// 显示更多操作
export const MoreOptionsBtn = ({ menuList, OptionsEvent }) => {
    const { runAsync } = useRequest(Http, { manual: true })
    const OptionsList = {
        CameraEnable: { url: 'posCameraUpdateIsEnabled', success: '设备全部启用' },
        CameraDisable: { url: 'posCameraUpdateIsNotEnabled', success: '设备全部禁用' },
        CameraOffLine: { url: 'posCameraUpdateIsEnabledByOnline', success: '离线设备已禁用' },
        CameraStatus: { url: 'posCameraStatusSync', success: '同步在线状态' },
        // CameraCloudSync: { url: 'posCameraCloudSync', success: '同步萤石云状态' },
    }
    const onMenuClick = ({ key }) =>
        runAsync({ url: OptionsList[key].url }).then(() =>
            OptionsEvent.emit({ key: 'OK', value: OptionsList[key].success }),
        )
    return <Dropdown.Button menu={{ items: menuList, onClick: onMenuClick }}> 更多操作</Dropdown.Button>
}
// 隐藏更多操作
export const OtherBtn = ({ record, menus, OptionsEvent, pageHeaderData, api, api2, data, Permission }) => {
    const PopupList = { AddressSelectModal, ProjectFileMenuModal }
    const [Title, setTitle] = useState()
    const [PopupSelect, setPopupSelect] = useState()
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    const [APIList, setAPIList] = useState([])

    return (
        <>
            <TableDropdown
                onSelect={key => {
                    switch (key) {
                        case 'FieldModal':
                            OptionsEvent.emit({ key, data: record })
                            break
                        case 'exportFile':
                            ExportExcel(api, data)
                            break
                        case 'exportFile2':
                            ExportExcel(api2, data)
                            break
                        case 'AddressSelectModal':
                            setPopupSelect('AddressSelectModal')
                            setTitle('公司位置选择')
                            setTrue()
                            break
                        case 'ProjectFileMenuModal':
                            setAPIList(menus.find(v => v.key === 'ProjectFileMenuModal').list)
                            setPopupSelect('ProjectFileMenuModal')
                            setTitle('PPP建设模式管理程序文件配置')
                            setTrue()
                            break
                        case 'ProjectBuildListModal':
                            setAPIList(menus.find(v => v.key === 'ProjectBuildListModal').list)
                            setPopupSelect('ProjectFileMenuModal')
                            setTitle('建设程序文件配置')
                            setTrue()
                            break
                        default:
                            OptionsEvent.emit({
                                key: 'TwoModal',
                                data: record,
                                towKey: key,
                                pageHeaderData,
                                Permission,
                            })
                            break
                    }
                }}
                menus={menus}
            />
            {ModalState &&
                (() => {
                    const Template = PopupList[PopupSelect]
                    return (
                        <Template
                            Off={setFalse}
                            title={Title}
                            record={record}
                            api={api}
                            data={data}
                            uuid={record.uuid}
                            APIList={APIList}
                        />
                    )
                })()}
        </>
    )
}
// 新建
export const AddedBtn = ({ OptionsEvent, data, AddTo, uuid, title }) => {
    return (
        <Button
            key="add"
            icon={<PlusOutlined />}
            type="primary"
            onClick={() => OptionsEvent.emit({ key: 'DataModal', data, AddTo, uuid })}
        >
            {title || '新增'}
        </Button>
    )
}

export const ProjectBuildingPaymentStatButton = ({ OptionsEvent, url, title }) => {
    const [Status, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button key="add" icon={<PlusOutlined />} type="primary" onClick={setTrue}>
                新建
            </Button>
            {Status && (
                <ProjectBuildingPaymentStatModal OptionsEvent={OptionsEvent} url={url} title={title} Off={setFalse} />
            )}
        </>
    )
}

// 修改
export const ModifyBtn = ({ OptionsEvent, data, record, uuid }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => OptionsEvent.emit({ key: 'DataModal', data, record, uuid })}
        >
            修改
        </Button>
    )
}
// 删除
export const DeleteBtn = ({ OptionsEvent, data, record }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            danger
            onClick={() => {
                OptionsEvent.emit({ key: 'DeleteModal', data, record })
            }}
        >
            删除
        </Button>
    )
}
// 提交
export const SubmitModal = ({ OptionsEvent, data, record, title }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => OptionsEvent.emit({ key: 'DeleteModal', data, record })}
        >
            {title}
        </Button>
    )
}
// 追加
export const AddedMenu = ({ OptionsEvent, data, AddTo }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => OptionsEvent.emit({ key: 'AddedMenu', data, AddTo })}>
            追加
        </Button>
    )
}
// 查看附件
export const SeeEnclosure = ({ data, title }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean()
    return (
        <>
            <Button className="TableBtn" type="link" onClick={() => setTrue()}>
                {title || '查看附件'}
            </Button>
            {ModalState && <SeeEnclosureModal data={data} Off={setFalse} />}
        </>
    )
}
// 编辑场景
export const ScenesDetails = ({ OptionsEvent, record }) => {
    const { category } = record
    return (
        <>
            <Button
                className="TableBtn"
                type="link"
                onClick={() => {
                    switch (category) {
                        case 'bb84e25e-1b42-44b5-bae8-7d8c7eb44814':
                            // mars3D
                            OptionsEvent.emit({ key: 'Mar3dModal', record })
                            break
                        case 'a3d3ab74-3301-454d-becc-20cb15483295':
                            // forge
                            OptionsEvent.emit({ key: 'ForgeModal', record })
                            break
                        case '180d760e-4863-49ac-8a68-a6a4596e02e7':
                            // 720
                            break
                        case '98a595c6-4235-40a9-ba96-d53bab467f77':
                            // cesiumlab2
                            break
                        default:
                            break
                    }
                }}
            >
                场景详情
            </Button>
        </>
    )
}
// 导出excel
export const ExportExcelBtn = ({ title, api, data }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => ExportExcel(api, data)}>
            {title || '导出excel'}
        </Button>
    )
}
// 导出Image
export const ExportImageBtn = ({ title, api, data }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => ExportExcel(api, data)}>
            {title || '导出excel'}
        </Button>
    )
}

// 修改数据状态
export const ModifyDataStateBtn = ({ title, OptionsEvent, data, danger }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            danger={danger}
            onClick={() => OptionsEvent.emit({ key: 'ModifyDataState', data })}
        >
            {title}
        </Button>
    )
}
// 查看二维码
export const SeeQRcodeBtn = ({ data }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean()
    return (
        <>
            <Button className="TableBtn" type="link" onClick={() => setTrue()}>
                二维码
            </Button>
            {ModalState && <QRcode data={data} Off={setFalse} />}
        </>
    )
}

export const CanvasQRcodeBtn = ({ data }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean()
    return (
        <>
            <Button className="TableBtn" type="link" onClick={() => setTrue()}>
                二维码
            </Button>
            {ModalState && <CanvasQRcodeModal data={data} Off={setFalse} />}
        </>
    )
}

// 打开二级页
export const TwoModalBtn = ({ OptionsEvent, towKey, data, title, pageHeaderData, Permission, DefaultData }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() =>
                OptionsEvent.emit({ key: 'TwoModal', data, towKey, pageHeaderData, Permission, DefaultData })
            }
        >
            {title}
        </Button>
    )
}

export const ThrModalBtn = ({ OptionsEvent, title, data, value }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => OptionsEvent.emit({ key: 'ThrModal', data, value })}>
            {title}
        </Button>
    )
}

// 打开二级页
export const TwoModalAddBtn = ({ OptionsEvent, towKey, data, title, pageHeaderData, Permission }) => {
    return (
        <Button
            className="TableBtn"
            icon={<PlusOutlined />}
            type="primary"
            onClick={() => OptionsEvent.emit({ key: 'TwoModal', data, towKey, pageHeaderData, Permission })}
        >
            {title}
        </Button>
    )
}

// 二级页添加按钮
export const TwoAddBtn = ({ upDataEvent, title, ThrKey, value, data, PPPEvent }) => {
    return (
        <Button
            className="TableBtn"
            icon={<PlusOutlined />}
            type="primary"
            onClick={() => {
                upDataEvent.emit({ type: ThrKey, value, data, PPPEvent })
            }}
        >
            {title}
        </Button>
    )
}
// 二级页删除按钮
export const ThrDeleteBtn = ({ upDataEvent, additional, record, data, title, PPPEvent }) => {
    return (
        <Button
            type="link"
            danger={title ? false : true}
            onClick={() => upDataEvent.emit({ type: 'delete', value: record, data, additional, PPPEvent })}
        >
            {title || '删除'}
        </Button>
    )
}
// 打开三级页
// 二级页添加按钮
export const OpenThrBtn = ({ upDataEvent, title, ThrKey, value, data, Permission }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => upDataEvent.emit({ key: ThrKey, type: ThrKey, value, data, Permission })}
        >
            {title}
        </Button>
    )
}
// 打开EXCEL编辑
export const TestExcelBtn = ({ upDataEvent, title, LabReportTemplatesUuid, TestTypeUuid, SampleItemUuid }) => {
    return (
        <Button
            className="TableBtn"
            type="link"
            size="small"
            onClick={() =>
                upDataEvent.emit({ type: 'TestExcel', data: { LabReportTemplatesUuid, TestTypeUuid, SampleItemUuid } })
            }
        >
            {title}
        </Button>
    )
}
// 修改场景设置
export const SceneDetailsBtn = ({ OptionsEvent, data }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => OptionsEvent.emit({ key: 'NewSceneDetails', data })}>
            场景详情
        </Button>
    )
}
// 地图获取经纬度信息
export const GetMapAddressBtn = ({ title, record, api, data }) => {
    const [Modal, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title}
            </Button>
            {Modal && <AddressSelectModal Off={setFalse} title={title} record={record} api={api} data={data} />}
        </>
    )
}
// 功能按钮
export const FunctionButton = ({ data, type, title }) => {
    const { runAsync: posUserResetPassword } = useRequest(Http, {
        manual: true,
        onSuccess: res => message.success('密码重置成功!'),
    })
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => {
                switch (type) {
                    case 'ResetPassword':
                        posUserResetPassword({ url: 'posUserResetPassword', path: [data.uuid] })
                        break
                    default:
                        break
                }
            }}
        >
            {title}
        </Button>
    )
}
// 按钮添加附件
export const AddAttachment = ({ title }) => {
    return (
        <Button
            className="TableBtn"
            icon={<PlusOutlined />}
            type="primary"
            onClick={() => {
                console.log('添加附件')
            }}
        >
            {title}
        </Button>
    )
}

// 直接修改数据状态
export const ModifyDataState = ({ title, type, upDataEvent, data }) => {
    return (
        <Button className="TableBtn" type="link" onClick={() => upDataEvent.emit({ type, data })}>
            {title}
        </Button>
    )
}

// 试验室审核处理
export const LabHandleButton = ({ title, api, uuid, OptionsEvent, groupId }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title || '处理意见'}
            </Button>
            {ModalState && (
                <LabHandleModal Off={setFalse} api={api} uuid={uuid} OptionsEvent={OptionsEvent} groupId={groupId} />
            )}
        </>
    )
}

// 修改试验室数据状态
export const LabIsEnabledState = ({ OptionsEvent, isEnabled, api, uuid, groupId }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => OptionsEvent.emit({ key: 'OK', value: '数据状态修改成功!' }),
    })
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => runAsync({ url: api, path: [uuid ? uuid : groupId, isEnabled === 0 ? 1 : 0] })}
            danger={isEnabled !== 0 && true}
        >
            {isEnabled === 0 ? '启用' : '禁用'}
        </Button>
    )
}
// 打开钢筋保护层曲线图,沥青极配
export const LabDetailsBtn = ({ title, uuid, type, className }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    let TemplateList = { LabCoverProtectorModal, LabReboundHammerModal, AsphaltCurveDatasModal }

    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title}
            </Button>
            {ModalState && (
                <>
                    {(() => {
                        const Template = TemplateList[type]
                        return <Template Off={setFalse} uuid={uuid} className={className} />
                    })()}
                </>
            )}
        </>
    )
}

// 项目菜单配置
export const ProjectMenuBtn = ({ title, uuid }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title}
            </Button>
            {ModalState && <ProjectFileMenuModal Off={setFalse} uuid={uuid} />}
        </>
    )
}

// Forge进度弹窗
export const ForgeProgressWindowBtn = ({ title, type, data }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={() => setTrue()}>
                {title}
            </Button>
            {ModalState && <ForgeBox Off={setFalse} type={type} data={data} />}
        </>
    )
}

export const FaceConfirmedBtn = ({ title, api, data, OptionsEvent }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () =>
            OptionsEvent.emit({
                key: 'OK',
                value: data.faceConfirmed === 0 ? '已取消人脸信息审核' : '人脸信息审核通过',
            }),
    })

    // posFaceConfirmed
    return (
        <Button className="TableBtn" type="link" onClick={() => runAsync({ url: api, data })}>
            {title}
        </Button>
    )
}

export const WeChatMenuSetUp = ({ title, data }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title}
            </Button>
            {ModalState && <WeChatMenuItem Off={setFalse} data={data} />}
        </>
    )
}

export const UpLoadUserBtn = ({ title, path, url, OptionsEvent }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => OptionsEvent.emit({ type: 'OK', value: message.success('信息上传成功.') }),
    })
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => {
                console.log(2)
                runAsync({ url, path })
            }}
        >
            {title}
        </Button>
    )
}

export const SeeVideoBtn = ({ title, data }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)

    return (
        <>
            <Button className="TableBtn" type="link" onClick={() => setTrue()}>
                {title}
            </Button>
            {ModalState && <SeeLabVideoModal Off={setFalse} data={data} />}
        </>
    )
}

export const TestBtn = ({ title, data, path, url, OptionsEvent, tips }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => OptionsEvent.emit({ key: 'OK', value: tips || '调用成功.' }),
    })
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => {
                runAsync({ url, data, path })
            }}
        >
            {title}
        </Button>
    )
}
// 修改拌合站数据状态
export const CementMixingStationsIsEnabled = ({ OptionsEvent, isEnabled, api, uuid, groupId }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => OptionsEvent.emit({ key: 'OK', value: '数据状态修改成功!' }),
    })
    return (
        <Button
            className="TableBtn"
            type="link"
            onClick={() => runAsync({ url: api, path: [uuid ? uuid : groupId, isEnabled === 0 ? 1 : 0] })}
            danger={isEnabled !== 0 && true}
        >
            {isEnabled === 0 ? '启用' : '禁用'}
        </Button>
    )
}
// 拌合站审核处理
export const CementMixingStationsButton = ({ title, api, uuid, OptionsEvent, groupId }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title || '处理意见'}
            </Button>
            {ModalState && (
                <CementMixingStationsModal
                    Off={setFalse}
                    api={api}
                    uuid={uuid}
                    OptionsEvent={OptionsEvent}
                    groupId={groupId}
                />
            )}
        </>
    )
}

export const OpenExcelUrlBtn = ({ title, ExcelUrl, ExcelData }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    // OpenExcelUrlModal
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title || '打开Excel'}
            </Button>
            {ModalState && (
                <OpenExcelUrlModal Off={setFalse} url={ExcelUrl} data={ExcelData} title={title || '打开Excel'} />
            )}
        </>
    )
}
// 带条件的Excel
export const SelectExcelBtn = ({ OptionsEvent, type, title, url }) => {
    const click = () => {
        OptionsEvent.emit({ key: 'SelectExcel', url })
    }
    return (
        <Button className="TableBtn" type={type || 'link'} onClick={click}>
            {title || '导出Excel'}
        </Button>
    )
}

// 通用审核按钮
export const CommonExamine = ({ title, url, data, field, topic, content, path, OptionsEvent }) => {
    const [fieldText, fieldArray] = field
    const { runAsync: ExamineAPI } = useRequest(Http, {
        manual: true,
        onSuccess: () => {
            OptionsEvent.emit({ key: 'OK', value: '审核完成!' })
            setFalse()
        },
    })

    const ExamineFunction = e => {
        let DataData = data || {}
        let PathData = []
        DataData[fieldText] = Number(e)
        if (path.length !== 0) {
            path.forEach(item => (PathData = [...PathData, item === fieldText ? Number(e) : item]))
        }
        ExamineAPI({ url, data: DataData, path: PathData })
    }

    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    return (
        <>
            <Button className="TableBtn" type="link" onClick={setTrue}>
                {title || '审核'}
            </Button>
            {ModalState && (
                <Modal
                    className="ModalTitle"
                    open={true}
                    footer={null}
                    maskClosable={false}
                    onCancel={setFalse}
                    destroyOnClose
                    title={title}
                    centered
                >
                    <div className="CommonExamine">
                        <div>
                            <div className="topic">{topic}</div>
                            <div className="content">{content}</div>
                        </div>
                        <div>
                            {Object.keys(fieldArray).map((key, index) => (
                                <Button type="primary" key={index} onClick={() => ExamineFunction(key)}>
                                    {fieldArray[key]}
                                </Button>
                            ))}
                        </div>
                    </div>
                </Modal>
            )}
        </>
    )
}

// 再次驳回
export const RejectAgainButton = ({ title, OptionsEvent, url, path }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: res => OptionsEvent.emit({ key: 'OK', value: '信息已驳回!' }),
    })

    return (
        <Button className="TableBtn" type="link" danger onClick={() => runAsync({ url, path })}>
            {title || '审核'}
        </Button>
    )
}

// 单通道审核按钮
export const OneWayReviewBtn = ({ title, OptionsEvent, url, data, path, tips, danger }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: res => OptionsEvent.emit({ key: 'OK', value: tips || '操作成功!' }),
    })

    return (
        <Button className="TableBtn" type="link" danger={danger} onClick={() => runAsync({ url, data, path })}>
            {title || '审核'}
        </Button>
    )
}

// 评分上传按钮
export const ScoreManagementBtn = ({ OptionsEvent, type, title, tips, url }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: res => OptionsEvent.emit({ key: 'OK', value: tips || '操作成功!' }),
    })
    const [Options, setOptions] = useState()
    const [centerUuid, setCenterUuid] = useState()
    const [yearMonth, setYearMonth] = useState(dayjs())

    const { runAsync: getCenter } = useRequest(Http, {
        manual: true,
        onSuccess: res => {
            setCenterUuid(res[0].uuid)
            setOptions(res.map(({ uuid, centName }) => ({ label: centName, value: uuid })))
        },
    })
    useEffect(() => {
        getCenter({ url: 'getDataSynchronizationGetSelects' })
    }, [getCenter])
    const Submit = () => {
        const path = [centerUuid, type, yearMonth.format('YYYY-MM')]
        runAsync({ url, path })
    }

    return (
        <>
            <Select style={{ width: 200 }} value={centerUuid} options={Options} onChange={setCenterUuid} />
            <DatePicker value={yearMonth} onChange={setYearMonth} picker="month" />
            <Button className="TableBtn" onClick={Submit}>
                {title || '上传'}
            </Button>
        </>
    )
}

export const SampleSourceBtn = ({ uuid, options, url, OptionsEvent, tips }) => {
    const [ModalState, { setTrue, setFalse }] = useBoolean(false)
    const SelectEvent = useEventEmitter()
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => {
            OptionsEvent.emit({ key: 'OK', value: tips || '操作成功!' })
            setFalse()
        },
    })
    SelectEvent.useSubscription(val => {
        runAsync({ url, path: [uuid, val] })
    })
    return (
        <>
            <Button type="link" className="TableBtn" onClick={setTrue}>
                设置样品来源
            </Button>
            {ModalState && (
                <SelectModal Off={setFalse} title="设置样品来源" options={options} SelectEvent={SelectEvent} />
            )}
        </>
    )
}

export const LaboratoryUpload = ({ title, options, url, uuid, OptionsEvent, tips }) => {
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => OptionsEvent.emit({ key: 'OK', value: tips || '操作成功!' }),
    })

    const SelectEvent = useEventEmitter()
    SelectEvent.useSubscription(val => runAsync({ url, path: [val, uuid, 1] }))

    const click = () => {
        OptionsEvent.emit({
            key: 'ModalBox',
            data: {
                title: '上传试验数据',
                width: 800,
                type: 'SelectModal',
                data: { label: '上传位置', options, SelectEvent },
            },
        })
    }

    return (
        <Button type="link" className="TableBtn" onClick={click}>
            {' '}
            {title}
        </Button>
    )
}

export const InputModalBtn = ({ title, label, url, data, OptionsEvent, tips }) => {
    console.log(123)
    const { runAsync } = useRequest(Http, {
        manual: true,
        onSuccess: () => {
            OptionsEvent.emit({ key: 'OK', value: tips || '操作成功!' })
        },
    })
    const SelectEvent = useEventEmitter()
    SelectEvent.useSubscription(val => {
        if (url === 'posScoreManagementAddProjectScore') {
            console.log(data, val)
        } else {
            runAsync({ url, data: { ...data, notLabDataReason: val }, path: [data.uuid] })
        }
    })

    const click = () => {
        OptionsEvent.emit({
            key: 'ModalBox',
            data: {
                type: 'InputModal',
                data: { label: label || '原因', SelectEvent, title: `编辑${label || '原因'} `, width: 800 },
            },
        })
    }
    return (
        <Button type="link" className="TableBtn" onClick={click}>
            {title}
        </Button>
    )
}

// 张拉/压浆匹配
export const TensionMateButton = ({ OptionsEvent, title, componentId, url, tips, smallTitle, type }) => {
    const SmallEvent = useEventEmitter()
    SmallEvent.useSubscription(() => OptionsEvent.emit({ key: 'OK', value: tips }))
    const click = () => {
        OptionsEvent.emit({
            key: 'ModalBox',
            data: { type, data: { title: smallTitle, label: '梁', width: 800, url, componentId, tips, SmallEvent } },
        })
    }
    return (
        <Button type="link" className="TableBtn" onClick={click}>
            {title}
        </Button>
    )
}

// 张拉/压浆详情
export const TensionDetailsButton = ({ OptionsEvent, title, children, List, smallTitle, type }) => {
    const click = () => {
        OptionsEvent.emit({
            key: 'ModalBox',
            data: {
                type,
                data: { title: smallTitle, children, List, width: 1400 },
            },
        })
    }
    return (
        <Button type="link" className="TableBtn" onClick={click}>
            {title}
        </Button>
    )
}
